<%--
 *  File:   FileColumnMappingCustomer.jsp
 *  Desc:	
 *
 *  Date	  :	 2010-07-12 11:25        		    
 *  Author	:  kenfang
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
	//init param
  String privilegeCode = "E0513,E0514";
  String strModuleName = "CFM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>

<html>
<head>
<title>FileColumnMappingCustomer</title>
<PageFlow:CheckPageFlow pageName="p_columnmappingcustomer"/>
<%@ include file="/inc/AlertError.inc" %>
<%
  Vector details = (Vector)pageContext.getAttribute("details");
  if(details == null) details = new Vector();
  Vector allnotusedfields=(Vector)pageContext.getAttribute("allfields");
  if(allnotusedfields == null) allnotusedfields = new Vector();
  String disabled = "disabled";
  String strIsCheckQty = new String("");
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript">

function page_add()
{
    if(!checkALLElems(document.getElementById("newdetail"))) return;
    if(document.cform.ischeckqtyflag.checked)
  	{
    	document.cform.ischeckqty.value = "Y";
  	}
  	else
  	{
    	document.cform.ischeckqty.value = "N";  
  	}
    cform.actionname.value = "add";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_delete()
{
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_save()
{
    if(!checkALLElems(document.getElementById("olddetail"))) return;
    cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
var index = '';
function page_setOrg(id,name,code)
{
	if(!index && index!=0){
		  document.cform.custmerid.value = id;
		  document.cform.orgcode.value = code;  
		  document.cform.orgname.value = name;
	}else {
		document.getElementsByName('orgcode'+index)[0].value = code;
		document.getElementsByName('orgname'+index)[0].value = name;
		document.getElementsByName('custmerid'+index)[0].value = id;
	}

  var remote = window.open("","newwindow");
  if (remote != null)
    remote.close();
  index = '';
}

function selectOrg(num){
	index = num;
	popup('<%=contextPath %>/masterdata/ogm/OrgSelect.jsp?<%= OvalTools.randomURL() %>&globalpccode=112','newwindow','height=450, width=600,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
}

function page_back(){
	parent.location.href="FileListRuleSummary.jsp?<%=OvalTools.randomURL()%>";
}

function setReadonly(){
	var numrows = cform.numrows.value;
	cform.orgname.disabled = "disabled";
	for(var i=0 ; i < numrows; i++){
		eval("cform.orgname"+i).disabled = "disabled";
		eval("cform.orgcode"+i).disabled = "disabled";
	}
}
function page_cleancode(type){
	var  datahandler = new  DataHandler();
	if(type == 'new'){
		if(cform.orgcode.value == ''){
			cform.orgcode.value = '';
			cform.orgname.value = '';
			cform.custmerid.value = '';
		}else {
			datahandler.add_params("orgcode" , cform.orgcode.value);
			datahandler.getResult("orgcode","cform.orgcode"); 
			datahandler.getResult("orgname","cform.orgname"); 
			datahandler.getResult("orgid","cform.custmerid"); 
			datahandler.add_job("j_getorgbycode");
		}		
	}

	datahandler.runDataHandler();	
}
</script>
<body style="overflow: auto;">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher" >
  <input type="hidden" name="pagename" value="p_columnmappingcustomer">
  <input type="hidden" name="actionname">
  <input type="hidden" name="numrows" value="<%= details.size() %>">

<table border=0 cellpadding=0 cellspacing=0 width="100%">
  <tr>
    <td valign=top>
      <table border=0 cellpadding=1 cellspacing=0 width="100%">
        <tr>
          <td bgcolor=#000000 style="PADDING-BOTTOM: 1px; PADDING-LEFT: 1px; PADDING-RIGHT: 1px; PADDING-TOP: 0px">
            <table bgcolor=#000000 border=0 cellpadding=0 cellspacing=0 width="100%">
              <tr>
                <td  bgcolor=#ffffff style="PADDING-BOTTOM: 3px; PADDING-LEFT: 3px; PADDING-RIGHT: 3px; PADDING-TOP: 3px">
                  <div id=div2 style="HEIGHT: 415px; OVERFLOW: auto">
                    <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">

<%--    top function buttons    --%>
<% if(!isView){%>
                    <tr>
                        <td colspan="20" class="td_right">
                          <a onclick="page_add();"><custom:button type="2" label="L_Add" imgsrc="add_btn.gif" border="0"/></a>
                          <%if(details.size()>0 ){%>
                          <!--<a onclick="page_save()"><custom:button type="2" label="L_Save" imgsrc="save_btn.gif" border="0"/></a>
                          --><a onclick="page_delete();"><custom:button type="2" label="L_Delete" imgsrc="delete_btn.gif" border="0"/></a>
                          <%}%>
                        </td>
                      </tr>
<%}%>
<tr  class="deepblue-left"> 
	<td width="22" class="title_center">&nbsp;</td>
	<td width="250" class="title_center"><%= label.getLabelName("L_VendorCode") %><font color="red">*</font></td>
	<td width="120" class="title_center"><%= label.getLabelName("L_VendorName") %></td>
	<td width="120" class="title_center"><%= label.getLabelName("L_IsCheckQty") %></td>
</tr>
<span id="olddetail" >
                      <logic:iterate id="onerow" collection="<%= details %>" indexId="idx">
                      <tr>
                        <td width="30">
                   <custom:checkbox disabled="<%=isView %>" property="customercolumnruleid" name="onerow" changedName="deleteids" styleClass="normalradio" />
                   
                        </td>
                        <td>&nbsp;<custom:write property="orgcode" name="onerow"/></td>
                        <td>&nbsp;<custom:write property="orgname" name="onerow"/></td>
						<td>&nbsp;<custom:write property="ischeckqty" name="onerow"/></td>
                       
                   </tr>
                      <tr>
                        <td style="display:none">
                            <custom:hidden property="customercolumnruleid" name="onerow" colIndex="<%=idx%>"/>
                            <custom:hidden property="custmerid" name="onerow" colIndex="<%=idx%>"/>
                            <custom:hidden property="columnmappingruleid" name="onerow" colIndex="<%=idx%>"/>
                            <custom:hidden property="filedatatype" name="onerow" colIndex="<%=idx%>"/>
                         </td>
                      </tr>
                      </logic:iterate>
</span>


<% if(!isView){%>
<span id="newdetail" >
                      <tr >
                        <td>&nbsp;</td>
                        <td><custom:text name="newdetail" property="orgcode" size="15"  command="notnull" label="L_VendorCode" onchange="page_cleancode('new')"/><a onclick="selectOrg()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a></td>
                        <td><custom:text name="newdetail" property="orgname" size="15" command="notnull" label="L_VendorName"/></td>
                        <td><input type="checkbox" name="ischeckqtyflag" class="normalradio" <%=JspHelper.filterNull( strIsCheckQty )%>></td>
                      </tr>

                      <tr>
                        <td style="display:none">
                            <custom:hidden property="custmerid"/>
                            <custom:hidden property="columnmappingruleid"/>
                            <custom:hidden property="filedatatype"/>
							<custom:hidden property="ischeckqty" name="newdetail"/>
                        </td>
                      </tr>
</span>
<%}%>
                    </table>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
         <tr><td class="summary_top"></td></tr>
         <tr>
           <td class="td_center">
          
             <a onclick="page_back();"><custom:button type="1" label="L_Back" imgsrc="new.gif" border="0" style="width:60"/></a>
          
           </td>
         </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
<script>
	setReadonly();
</script>
</html>